public class test1 {
    // 力扣 11.承最多水的容器  （双指针）
    public static void main(String[] args) {
        int[] height = {1, 2 ,1};
        int n = height.length;
        int left = 0;
        int right = 0;
        int max = 0;
        while (left != n-1  && right != n-1) {
            while (left != n-1  && right != n-1 && height[left] <= height[right]) {
                left++;//注意这里的数组下标越界问题
                max = Math.max(max, getCapacity(left, right ,height));
            }
            while (left != n-1  && right != n-1  && height[left] >= height[right]) {
                right++;//注意这里的数组下标越界问题
                max = Math.max(max, getCapacity(left, right ,height));
            }

        }
        System.out.println(getCapacity(left, right ,height));
        System.out.println(left);
        System.out.println(right);

    }

    private static int getCapacity(int left, int right,int[] heigh) {

        return Math.min(heigh[left], heigh[right]) * Math.abs(right - left);
    }


}
